home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / tmemchne / timemach.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-11-18  |  22.1 KB  |  635 lines

  1. VERSION 5.00
  2. Object = "{2384AED4-7A82-11D2-9F1B-BD2ED3523208}#6.0#0"; "BWTIMEMACHINE.OCX"
  3. Begin VB.Form Form1 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "BinaryWork Time Machine OCX - Sample"
  6.    ClientHeight    =   5865
  7.    ClientLeft      =   45
  8.    ClientTop       =   615
  9.    ClientWidth     =   9675
  10.    LinkTopic       =   "Form1"
  11.    LockControls    =   -1  'True
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   5865
  15.    ScaleWidth      =   9675
  16.    StartUpPosition =   2  'CenterScreen
  17.    Begin BWTimeMachine.TimeMachine TimeMachine1 
  18.       Left            =   3120
  19.       Top             =   1320
  20.       _ExtentX        =   926
  21.       _ExtentY        =   926
  22.    End
  23.    Begin VB.Frame Frame4 
  24.       Caption         =   "Special functions"
  25.       Height          =   2175
  26.       Left            =   5400
  27.       TabIndex        =   0
  28.       Top             =   3600
  29.       Width           =   4215
  30.       Begin VB.CommandButton Command17 
  31.          Caption         =   "Verify"
  32.          Height          =   255
  33.          Left            =   3000
  34.          TabIndex        =   1
  35.          Top             =   1800
  36.          Width           =   1095
  37.       End
  38.       Begin VB.TextBox Text19 
  39.          Height          =   285
  40.          Left            =   1800
  41.          TabIndex        =   14
  42.          ToolTipText     =   "type the month in the format MM"
  43.          Top             =   1800
  44.          Width           =   855
  45.       End
  46.       Begin VB.TextBox Text18 
  47.          Height          =   285
  48.          Left            =   480
  49.          TabIndex        =   15
  50.          ToolTipText     =   "type the year in the format YYYY"
  51.          Top             =   1800
  52.          Width           =   735
  53.       End
  54.       Begin VB.CommandButton Command16 
  55.          Caption         =   "Verify"
  56.          Height          =   375
  57.          Left            =   2280
  58.          TabIndex        =   16
  59.          Top             =   720
  60.          Width           =   1815
  61.       End
  62.       Begin VB.TextBox Text17 
  63.          Height          =   375
  64.          Left            =   120
  65.          TabIndex        =   17
  66.          ToolTipText     =   "type the year in the format YYYY to verify whether this year is a leap-year or not"
  67.          Top             =   720
  68.          Width           =   1935
  69.       End
  70.       Begin VB.Label Label21 
  71.          Caption         =   "Month"
  72.          Height          =   255
  73.          Left            =   1320
  74.          TabIndex        =   18
  75.          Top             =   1800
  76.          Width           =   495
  77.       End
  78.       Begin VB.Label Label20 
  79.          Caption         =   "Year"
  80.          Height          =   255
  81.          Left            =   120
  82.          TabIndex        =   19
  83.          Top             =   1800
  84.          Width           =   495
  85.       End
  86.       Begin VB.Label Label19 
  87.          Caption         =   "Type a especific year and a especific month to retrieve the number of days in the especific month"
  88.          Height          =   495
  89.          Left            =   120
  90.          TabIndex        =   20
  91.          Top             =   1200
  92.          Width           =   3975
  93.       End
  94.       Begin VB.Label Label18 
  95.          Caption         =   "Type an year in the textbox to verify whether the year is a year of leap ( 29 days in february ) ( ano bissexto)"
  96.          Height          =   495
  97.          Left            =   120
  98.          TabIndex        =   21
  99.          Top             =   240
  100.          Width           =   3975
  101.       End
  102.    End
  103.    Begin VB.Frame Frame3 
  104.       Caption         =   "DateDiff equivalent functions"
  105.       Height          =   2775
  106.       Left            =   120
  107.       TabIndex        =   38
  108.       Top             =   3000
  109.       Width           =   5175
  110.       Begin VB.CommandButton Command15 
  111.          Caption         =   "Apply"
  112.          Height          =   255
  113.          Left            =   1320
  114.          TabIndex        =   50
  115.          Top             =   1560
  116.          Width           =   2055
  117.       End
  118.       Begin VB.TextBox Text16 
  119.          Height          =   285
  120.          Left            =   4080
  121.          TabIndex        =   49
  122.          ToolTipText     =   "here will apear the number of years involving the diference of the two dates"
  123.          Top             =   2160
  124.          Width           =   855
  125.       End
  126.       Begin VB.TextBox Text15 
  127.          Height          =   285
  128.          Left            =   2760
  129.          TabIndex        =   47
  130.          ToolTipText     =   "here will apear the number of months involving the diference of the two dates"
  131.          Top             =   2160
  132.          Width           =   735
  133.       End
  134.       Begin VB.TextBox Text14 
  135.          Height          =   285
  136.          Left            =   600
  137.          TabIndex        =   45
  138.          ToolTipText     =   "here will apear the number of days involving the diference of the two dates"
  139.          Top             =   2160
  140.          Width           =   1455
  141.       End
  142.       Begin VB.TextBox Text13 
  143.          Height          =   285
  144.          Left            =   1320
  145.          TabIndex        =   42
  146.          ToolTipText     =   "type here the final date of the operation"
  147.          Top             =   1200
  148.          Width           =   2055
  149.       End
  150.       Begin VB.TextBox Text12 
  151.          Height          =   285
  152.          Left            =   1320
  153.          TabIndex        =   40
  154.          ToolTipText     =   "type here the initial date of the operation"
  155.          Top             =   600
  156.          Width           =   2055
  157.       End
  158.       Begin VB.Label Label17 
  159.          Caption         =   "Years"
  160.          Height          =   255
  161.          Left            =   3600
  162.          TabIndex        =   48
  163.          Top             =   2160
  164.          Width           =   615
  165.       End
  166.       Begin VB.Label Label16 
  167.          Caption         =   "Months"
  168.          Height          =   255
  169.          Left            =   2160
  170.          TabIndex        =   46
  171.          Top             =   2160
  172.          Width           =   855
  173.       End
  174.       Begin VB.Label Label15 
  175.          Caption         =   "Days"
  176.          Height          =   255
  177.          Left            =   120
  178.          TabIndex        =   44
  179.          Top             =   2160
  180.          Width           =   615
  181.       End
  182.       Begin VB.Label Label14 
  183.          Caption         =   "These are the diferences between the dates"
  184.          Height          =   255
  185.          Left            =   120
  186.          TabIndex        =   43
  187.          Top             =   1800
  188.          Width           =   4935
  189.       End
  190.       Begin VB.Label Label13 
  191.          Caption         =   "Type the final date in the same format as above"
  192.          Height          =   255
  193.          Left            =   120
  194.          TabIndex        =   41
  195.          Top             =   960
  196.          Width           =   4335
  197.       End
  198.       Begin VB.Label Label12 
  199.          Caption         =   "Type the initial date in the format yyyymmdd like it 19981225"
  200.          Height          =   375
  201.          Left            =   120
  202.          TabIndex        =   39
  203.          Top             =   240
  204.          Width           =   4935
  205.       End
  206.    End
  207.    Begin VB.Frame Frame2 
  208.       Caption         =   "Date calculations"
  209.       Height          =   3495
  210.       Left            =   5400
  211.       TabIndex        =   22
  212.       Top             =   0
  213.       Width           =   4215
  214.       Begin VB.TextBox Text11 
  215.          Height          =   285
  216.          Left            =   2040
  217.          TabIndex        =   37
  218.          ToolTipText     =   "type the value "
  219.          Top             =   1320
  220.          Width           =   2055
  221.       End
  222.       Begin VB.CommandButton Command14 
  223.          Caption         =   "Apply the operation"
  224.          Height          =   975
  225.          Left            =   120
  226.          TabIndex        =   35
  227.          Top             =   2400
  228.          Width           =   1815
  229.       End
  230.       Begin VB.TextBox Text10 
  231.          Height          =   285
  232.          Left            =   2040
  233.          TabIndex        =   34
  234.          ToolTipText     =   "result of the operation"
  235.          Top             =   3000
  236.          Width           =   2055
  237.       End
  238.       Begin VB.TextBox Text9 
  239.          Height          =   285
  240.          Left            =   2040
  241.          TabIndex        =   31
  242.          ToolTipText     =   "you can type directly here the operation , like +d to make operations involving days"
  243.          Top             =   2280
  244.          Width           =   2055
  245.       End
  246.       Begin VB.TextBox Text8 
  247.          Height          =   285
  248.          Left            =   2040
  249.          TabIndex        =   30
  250.          ToolTipText     =   "type here the date to be applied to the operation in the BW date format"
  251.          Top             =   600
  252.          Width           =   2055
  253.       End
  254.       Begin VB.CommandButton Command13 
  255.          Caption         =   "Decrease years -y"
  256.          Height          =   255
  257.          Left            =   120
  258.          TabIndex        =   28
  259.          Top             =   2040
  260.          Width           =   1695
  261.       End
  262.       Begin VB.CommandButton Command12 
  263.          Caption         =   "Decrease months -m"
  264.          Height          =   255
  265.          Left            =   120
  266.          TabIndex        =   27
  267.          Top             =   1680
  268.          Width           =   1695
  269.       End
  270.       Begin VB.CommandButton Command11 
  271.          Caption         =   "Decrease days -d"
  272.          Height          =   255
  273.          Left            =   120
  274.          TabIndex        =   26
  275.          Top             =   1320
  276.          Width           =   1695
  277.       End
  278.       Begin VB.CommandButton Command10 
  279.          Caption         =   "Add years +y"
  280.          Height          =   255
  281.          Left            =   120
  282.          TabIndex        =   25
  283.          Top             =   960
  284.          Width           =   1695
  285.       End
  286.       Begin VB.CommandButton Command9 
  287.          Caption         =   "Add months +m"
  288.          Height          =   255
  289.          Left            =   120
  290.          TabIndex        =   24
  291.          Top             =   600
  292.          Width           =   1695
  293.       End
  294.       Begin VB.CommandButton Command8 
  295.          Caption         =   "Add days +d"
  296.          Height          =   255
  297.          Left            =   120
  298.          TabIndex        =   23
  299.          Top             =   240
  300.          Width           =   1695
  301.       End
  302.       Begin VB.Label Label11 
  303.          Caption         =   "Type the value to be evaluated by the operation"
  304.          Height          =   495
  305.          Left            =   2040
  306.          TabIndex        =   36
  307.          Top             =   960
  308.          Width           =   2055
  309.       End
  310.       Begin VB.Label Label10 
  311.          Caption         =   "Here will apear the date with the result of the operation"
  312.          Height          =   375
  313.          Left            =   2040
  314.          TabIndex        =   33
  315.          Top             =   2640
  316.          Width           =   2055
  317.       End
  318.       Begin VB.Label Label9 
  319.          Caption         =   "Click the button to select the operation and here will apear the operation to be applied"
  320.          Height          =   615
  321.          Left            =   2040
  322.          TabIndex        =   32
  323.          Top             =   1680
  324.          Width           =   2055
  325.       End
  326.       Begin VB.Label Label8 
  327.          Caption         =   "Type the initial date (eight characters , YYYYMMDD)"
  328.          Height          =   375
  329.          Left            =   2040
  330.          TabIndex        =   29
  331.          Top             =   240
  332.          Width           =   2055
  333.       End
  334.    End
  335.    Begin VB.TextBox Text7 
  336.       Height          =   285
  337.       Left            =   4200
  338.       TabIndex        =   13
  339.       ToolTipText     =   "type the year to set your system date"
  340.       Top             =   2400
  341.       Width           =   975
  342.    End
  343.    Begin VB.Timer Timer1 
  344.       Interval        =   1000
  345.       Left            =   7680
  346.       Top             =   360
  347.    End
  348.    Begin VB.CommandButton Command7 
  349.       Caption         =   "Set the year of the system"
  350.       Height          =   255
  351.       Left            =   240
  352.       TabIndex        =   12
  353.       Top             =   2400
  354.       Width           =   2175
  355.    End
  356.    Begin VB.TextBox Text6 
  357.       Height          =   285
  358.       Left            =   4200
  359.       TabIndex        =   11
  360.       ToolTipText     =   "type the month to set your system date"
  361.       Top             =   2040
  362.       Width           =   975
  363.    End
  364.    Begin VB.CommandButton Command6 
  365.       Caption         =   "Set the month of the system"
  366.       Height          =   255
  367.       Left            =   240
  368.       TabIndex        =   10
  369.       Top             =   2040
  370.       Width           =   2175
  371.    End
  372.    Begin VB.TextBox Text5 
  373.       Height          =   285
  374.       Left            =   4200
  375.       TabIndex        =   9
  376.       ToolTipText     =   "type the day to set your system date"
  377.       Top             =   1680
  378.       Width           =   975
  379.    End
  380.    Begin VB.CommandButton Command5 
  381.       Caption         =   "Set the day of the system"
  382.       Height          =   255
  383.       Left            =   240
  384.       TabIndex        =   8
  385.       Top             =   1680
  386.       Width           =   2175
  387.    End
  388.    Begin VB.TextBox Text4 
  389.       Height          =   285
  390.       Left            =   4200
  391.       TabIndex        =   7
  392.       ToolTipText     =   "here will apear the year"
  393.       Top             =   1320
  394.       Width           =   975
  395.    End
  396.    Begin VB.CommandButton Command4 
  397.       Caption         =   "Get the year"
  398.       Height          =   255
  399.       Left            =   240
  400.       TabIndex        =   6
  401.       Top             =   1320
  402.       Width           =   2175
  403.    End
  404.    Begin VB.TextBox Text3 
  405.       Height          =   285
  406.       Left            =   4200
  407.       TabIndex        =   5
  408.       ToolTipText     =   "here will apear the month"
  409.       Top             =   960
  410.       Width           =   975
  411.    End
  412.    Begin VB.CommandButton Command3 
  413.       Caption         =   "Get the month"
  414.       Height          =   255
  415.       Left            =   240
  416.       TabIndex        =   4
  417.       Top             =   960
  418.       Width           =   2175
  419.    End
  420.    Begin VB.TextBox Text2 
  421.       Height          =   285
  422.       Left            =   4200
  423.       TabIndex        =   3
  424.       ToolTipText     =   "Here will apear the day"
  425.       Top             =   600
  426.       Width           =   975
  427.    End
  428.    Begin VB.CommandButton Command2 
  429.       Caption         =   "Get the day"
  430.       Height          =   255
  431.       Left            =   240
  432.       TabIndex        =   2
  433.       Top             =   600
  434.       Width           =   2175
  435.    End
  436.    Begin VB.Frame Frame1 
  437.       Caption         =   "Date functions"
  438.       Height          =   2895
  439.       Left            =   120
  440.       TabIndex        =   51
  441.       Top             =   0
  442.       Width           =   5175
  443.       Begin VB.TextBox Text1 
  444.          Height          =   285
  445.          Left            =   4080
  446.          TabIndex        =   60
  447.          Top             =   240
  448.          Width           =   975
  449.       End
  450.       Begin VB.CommandButton Command1 
  451.          Caption         =   "Get the date"
  452.          Height          =   255
  453.          Left            =   120
  454.          TabIndex        =   58
  455.          Top             =   240
  456.          Width           =   2175
  457.       End
  458.       Begin VB.Label Label7 
  459.          Caption         =   "Date of the system"
  460.          Height          =   255
  461.          Left            =   2520
  462.          TabIndex        =   59
  463.          Top             =   240
  464.          Width           =   1455
  465.       End
  466.       Begin VB.Label Label6 
  467.          Caption         =   "Type the year"
  468.          Height          =   255
  469.          Left            =   2520
  470.          TabIndex        =   57
  471.          Top             =   2400
  472.          Width           =   1455
  473.       End
  474.       Begin VB.Label Label5 
  475.          Caption         =   "Type the month"
  476.          Height          =   255
  477.          Left            =   2520
  478.          TabIndex        =   56
  479.          Top             =   2040
  480.          Width           =   1455
  481.       End
  482.       Begin VB.Label Label4 
  483.          Caption         =   "Type the day"
  484.          Height          =   255
  485.          Left            =   2520
  486.          TabIndex        =   55
  487.          Top             =   1680
  488.          Width           =   1335
  489.       End
  490.       Begin VB.Label Label3 
  491.          Caption         =   "Year"
  492.          Height          =   255
  493.          Left            =   2520
  494.          TabIndex        =   54
  495.          Top             =   1320
  496.          Width           =   1455
  497.       End
  498.       Begin VB.Label Label2 
  499.          Caption         =   "Month"
  500.          Height          =   255
  501.          Left            =   2520
  502.          TabIndex        =   53
  503.          Top             =   960
  504.          Width           =   1455
  505.       End
  506.       Begin VB.Label Label1 
  507.          Caption         =   "Day"
  508.          Height          =   255
  509.          Left            =   2520
  510.          TabIndex        =   52
  511.          Top             =   600
  512.          Width           =   1455
  513.       End
  514.    End
  515. Attribute VB_Name = "Form1"
  516. Attribute VB_GlobalNameSpace = False
  517. Attribute VB_Creatable = False
  518. Attribute VB_PredeclaredId = True
  519. Attribute VB_Exposed = False
  520. 'This application is a sample to demonstrate the possibilities of the
  521. 'BinaryWork Time Machine OCX
  522. 'This OCX was developed to fix some bugs in the date data type ( the bug is explained in the help file ), and
  523. 'to make your applications compliant with the international market
  524. 'and to avoid the Y2K problem
  525. 'This sample will explore all the possibilities of the OCX
  526. '                                                       developed by BinaryWork Corp.     BynaryWork@geocities.com
  527. Private Sub about_Click()
  528. TimeMachine1.AboutBox
  529. End Sub
  530. Private Sub Command1_Click()
  531. Text1.Text = TimeMachine1.GetDate
  532. End Sub
  533. Private Sub Command10_Click()
  534. Text9.Text = "+y"
  535. End Sub
  536. Private Sub Command11_Click()
  537. Text9.Text = "-d"
  538. End Sub
  539. Private Sub Command12_Click()
  540. Text9.Text = "-m"
  541. End Sub
  542. Private Sub Command13_Click()
  543. Text9.Text = "-y"
  544. End Sub
  545. Private Sub Command14_Click()
  546. If Len(Text8.Text) <> 8 Then MsgBox "you need to type the date in the format yyyymmdd , and without separators , like it 19981225  ": Text8.SetFocus: Exit Sub
  547. If Len(Text9.Text) = 0 Then MsgBox "you need to select the operation , the valid operations are  +d +m +y -d -m -y ": Text9.SetFocus: Exit Sub
  548. If Len(Text11.Text) = 0 Then MsgBox "you need to select the value to be evaluated by the operation , to add 10 days to your date , type 10 in the value textbox and +d in the operation textbox ": Text11.SetFocus: Exit Sub
  549. Dim Ret As Boolean
  550. Dim Myreturn As Long
  551. Text10.Text = 0  ' the function is expecting for a long in the finaldate variable , this is why we need to initiate the variable with a 0
  552. Myreturn = Text10.Text  'the result will be retrieved in the myfunction variable
  553. Ret = TimeMachine1.CalcDate(Text9.Text, Text11.Text, Text8.Text, Myreturn)
  554. Text10.Text = Myreturn  '<- this is the data retrieved by the operation
  555. If Ret = True Then
  556. MsgBox "the operation was evaluated successfully"
  557. MsgBox "an error occurred , please , verify the data entered  or read the help file "
  558. End If
  559. End Sub
  560. Private Sub Command15_Click()
  561. If Len(Text12.Text) <> 8 Then MsgBox "You need to type the initial date , 8 characters) : text12.setfocus : exit sub"
  562. If Len(Text13.Text) <> 8 Then MsgBox "You need to type the final date , 8 characters) : text13.setfocus : exit sub"
  563. Dim Ret As Boolean
  564. Dim mYday As Long
  565. Dim mYyear As Long
  566. Dim mYmonth As Long
  567. Ret = TimeMachine1.BWDatediff(Text12.Text, Text13.Text, mYday, mYmonth, mYyear)
  568. Text14.Text = mYday
  569. Text15.Text = mYmonth
  570. Text16.Text = mYyear
  571. If Ret = False Then MsgBox "an error occurred , please verify the date entered"
  572. End Sub
  573. Private Sub Command16_Click()
  574. If Len(Text17.Text) <> 4 Then MsgBox "type the year with four digits": Exit Sub
  575. Dim Ret As Long
  576. Ret = TimeMachine1.VerifyYearOfLeap(Text17.Text)
  577. If Ret Then
  578. MsgBox "this year is a year of leap"
  579. MsgBox "this year isnot a year of leap"
  580. End If
  581. End Sub
  582. Private Sub Command17_Click()
  583. If Len(Text18.Text) <> 4 Then MsgBox "type four digits to the year": Exit Sub
  584. Dim Ret As Long
  585. Ret = TimeMachine1.DaysInaMonth(Text18.Text, Text19.Text)
  586. MsgBox "Number of days in the especific month :  " & Ret
  587. End Sub
  588. Private Sub Command2_Click()
  589. Text2.Text = TimeMachine1.GetDay
  590. End Sub
  591. Private Sub Command3_Click()
  592. Text3.Text = TimeMachine1.GetMonth
  593. End Sub
  594. Private Sub Command4_Click()
  595. Text4.Text = TimeMachine1.GetYear
  596. End Sub
  597. Private Sub Command5_Click()
  598. Dim Ret As Boolean
  599. Ret = TimeMachine1.SetDay(Text5.Text)
  600. If Ret = True Then
  601. MsgBox "the day was set successfully ", , "Time Machine"
  602. MsgBox "The function retrieve an error , please verify whether the value entered is correct to a day", , "Time Machine"
  603. End If
  604. End Sub
  605. Private Sub Command6_Click()
  606. Dim Ret As Boolean
  607. Ret = TimeMachine1.SetMonth(Text6.Text)
  608. If Ret = True Then
  609. MsgBox "the month was set successfully ", , "Time Machine"
  610. MsgBox "The function retrieve an error , please verify whether the value entered is correct to a month", , "Time Machine"
  611. End If
  612. End Sub
  613. Private Sub Command7_Click()
  614. Dim Ret As Boolean
  615. Ret = TimeMachine1.SetYear(Text7.Text)
  616. If Ret = True Then
  617. MsgBox "the year was set successfully ", , "Time Machine"
  618. MsgBox "The function retrieve an error , please verify whether the value entered is correct to a year", , "Time Machine"
  619. End If
  620. End Sub
  621. Private Sub Command8_Click()
  622. Text9.Text = "+d"
  623. End Sub
  624. Private Sub Command9_Click()
  625. Text9.Text = "+m"
  626. End Sub
  627. Private Sub Label2_Click()
  628. End Sub
  629. Private Sub Timer1_Timer()
  630. 'obviously our ocx dont need the date data type of VB
  631. 'we are using it only to show the date in the known method
  632. 'and as you obviously know we dont recommend the use of the date data type ( if you want to develop international applications )
  633. Form1.Caption = "BinaryWork Time Machine OCX - Sample - System date : " & Date   'please , dont use the date data type in your applications , this will avoid problems in the future
  634. End Sub
  635.